<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../jquery-3.3.1.min.js"></script>
    <script src="../vue.js"></script>
</head>

<body>
    <div id="app">
        <input type="text" v-model.lazy='uname'>
        <span>{{tip}}</span>
    </div>
    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                uname: "",
                tip: ''
            },
            methods: {
                checkName: function(uname) {
                    var that = this;
                    setTimeout(function() {
                        if (uname == 'admin') {
                            that.tip = '存在'
                        } else {
                            that.tip = '可以';
                        }
                    }, 2000);
                }
            },
            watch: {
                uname: function(val) {
                    this.checkName(val);
                    this.tip = '正在验证'
                }
            }
        });
    </script>
</body>

</html>